package team.knowers.qzh.qzhgrame.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import team.knowers.qzh.qzhgrame.common.convention.result.Result;
import team.knowers.qzh.qzhgrame.common.convention.result.Results;
import team.knowers.qzh.qzhgrame.dto.req.AddCourseContentReqDTO;
import team.knowers.qzh.qzhgrame.dto.req.DeleteCourseContentReqDTO;
import team.knowers.qzh.qzhgrame.dto.req.UpdateCourseContentReqDTO;
import team.knowers.qzh.qzhgrame.dto.resp.AllCourseContentRespDTO;
import team.knowers.qzh.qzhgrame.service.CourseContentGrameService;

import java.util.List;

@RestController
@RequiredArgsConstructor
public class CourseContentGrameController {
    private final CourseContentGrameService courseContentGrameService;
    /**
     * 创建段落

     */
    @PostMapping("/api/qzh-server/admin/v1/coursecontent/add")
    public Result<Integer> addCourseContent(@RequestBody AddCourseContentReqDTO req)
    {
        return  Results.success(courseContentGrameService.addCourseContent(req));
    }
    /**
     * 删除段落
     *
     */
    @PutMapping("/api/qzh-server/admin/v1/coursecontent/delete/{id}")
    public Result<Integer> deleteCourseContent(@PathVariable("id") Long id)
    {
        return Results.success(courseContentGrameService.deleteCourseContent(id));
    }
    /**
     * 修改段落
     */
    @PutMapping("/api/qzh-server/admin/v1/coursecontent/update")
    public Result<Integer> updateCourseContent(@RequestBody UpdateCourseContentReqDTO req)
    {
        return Results.success(courseContentGrameService.updateCourseContent(req));
    }
    /**
     * 根据章节id展示章节内容
     */
    @GetMapping("/api/qzh-server/admin/v1/coursecontent/show/{id}")
    public Result<List<AllCourseContentRespDTO>> shouCourseContent(@PathVariable("id") Long id)
    {
        return Results.success(courseContentGrameService.shouCourseContent(id));
    }
}
